package com.cs.vessel.breakdown;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.ui.IWorkbenchWindow;

import com.cs.vessel.breakdown.wizards.AccidentNewWizard;

public class LaunchAccidentNewWizardAction extends Action {

    private final IWorkbenchWindow window;

    private IStructuredSelection selection;

    /**
     * Getter for selection.
     * 
     * @return the selection
     */
    public IStructuredSelection getSelection() {
        return this.selection;
    }

    /**
     * Sets the selection.
     * 
     * @param selection the selection to set
     */
    public void setSelection(IStructuredSelection selection) {
        this.selection = selection;
    }

    public LaunchAccidentNewWizardAction(String text, IWorkbenchWindow window) {
        super(text);
        this.window = window;
        // The id is used to refer to the action in a menu or toolbar
        setId(ICommandIds.CMD_OPEN_MESSAGE);
        // Associate the action with a pre-defined command, to allow key bindings.
        setActionDefinitionId(ICommandIds.CMD_OPEN_MESSAGE);
        setImageDescriptor(Activator.getImageDescriptor("/icons/accident.gif"));
    }

    public void run() {
        AccidentNewWizard wizard = new AccidentNewWizard();
        wizard.init(window.getWorkbench(), selection);
        WizardDialog dialog = new WizardDialog(window.getShell(), wizard);
        dialog.create();
        dialog.open();
    }

}
